﻿@using ZBJF.Warranty.WebProvider.AdminPemission
@section Header{
    @Styles.Render("~/Content/chosen")
}
@model List<ZBJF.Warranty.Model.InsuranceWarrantyRecordStatus>
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="nav nav-tabs">
            <li class="active">
                <a href="/InsuranceWarrantyDealWith/InsuranceWarrantyRecordStatusIndex">
                    自定义工单状态
                </a>
            </li>
            <li class="Add-R">
                <a href="/InsuranceWarrantyDealWith/StatusReasonIndex/0">
                    状态备注列表
                </a>
            </li>
        </ul>
    </div>
    <div class="page-content">
        <div class="widget-main">
            <label class="Add-R">
                <a id="AddNewRole" class="btn btn-xs btn-primary" data-toggle="modal" href="" onclick="showAddNewAdmin()" title="添加新字段">
                    <i class="icon-plus-sign bigger-130"></i>
                    添加新字段
                </a>
            </label>
            <div class="table-responsive">
                <div class="table_top"></div>
                <div class="categoryTree">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>状态字段名称</th>
                                <th>状态字段编码</th>
                                <th>是否启用</th>
                                <th>最后修改人</th>
                                <th>最后修改时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @Html.Action("ShowStatusList", "InsuranceWarrantyDealWith", new { listPage = Model, pid = 0, layer = 0 })
                        </tbody>
                    </table>
                </div>
                <div class="table_bottom"></div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ShowAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    @RenderPage("DisplayTemplates/EditStatusForm.cshtml", new { ItemList = Model.Where(m => m.ParentId == 0) })
</div>
@section scripts{
    @Scripts.Render("~/bundles/chosen")
    @Scripts.Render("~/bundles/permission")
    <script type="text/javascript">
        $(function () {
            $("#ParentID").chosen();
            $("#ActionListId").chosen();
        });

        function showAddNewAdmin(ParentId) {
            document.getElementById("UpdateStatusForm").reset(); //清空表单
            $("#ParentCode").val(""); //清空表单
            $("#ID").val(0);
            if ($("#ParentId option[value='" + ParentId + "']:selected").length < 1) {
                $("#ParentId option").attr("selected", false);
                $("#ParentId option[value='" + ParentId + "']").attr("selected", "selected");
                $("#ParentCode").val($("#ParentId option[value='" + ParentId + "']").attr("StatusCode"));
            }
            $('#ShowAdd').modal();
        }

        function ShowEidtDialog(ID, StatusName, StatusCode, ParentId, IsAvailable) {
            clearForm("UpdateStatusForm");
            $("#ID").val(ID);
            $("#StatusName").val(StatusName);
            $("#StatusCode").val(StatusCode);
            if (IsAvailable == true) {
                $("input[name='IsAvailable']").eq(1).removeAttr("checked");
                $("input[name='IsAvailable']").eq(0).attr("checked", "checked");
            } else {
                $("input[name='IsAvailable']").eq(1).attr("checked", "checked");
                $("input[name='IsAvailable']").eq(0).removeAttr("checked");
            }
            if ($("#ParentId option[value='" + ParentId + "']:selected").length < 1) {
                $("#ParentId option").attr("selected", false);
                $("#ParentId option[value='" + ParentId + "']").attr("selected", "selected");
            }
            $('#ShowAdd').modal();
        }

        function UpdateInsuranceWarrantyRecordStatus(id, isAvailable, url) {
            UpdateStatus(id, isAvailable, url, function () {
                window.location.href = window.location.href;
            })
        }
    </script>
}
